package Server;

import java.util.Timer;

import Database.mysqlConnection;

/**
 *@author Juan Alapin - 324507516
 *@author Giora Yaffe - 036551281
 *@author Shachar Gritzman - 300174026
 *@author Nir Porat - 021515580
*/


public class Scheduler {
	
	/**
	 * This class schedules all the scheduled tasks for this server.
	 * Each task will get called on pre-determined time
	 */
	
	public final static long DAY_IN_MILLIES = 60 * 60 * 24 * 1000;									//sec * min * hour * milliseconds = 1 Day in millies
	public final static long WEEK_IN_IN_MILLIES = DAY_IN_MILLIES * 7;

	public final static long DAY_IN_MILLIES_PRESENTATION = 60 * 1 * 1000;							// 5 minutes in millies - for presentation only! - simluate a day
	public final static long WEEK_IN_IN_MILLIES_PRESENTATION = DAY_IN_MILLIES_PRESENTATION ; 		// 10 minutes in millies - for presentation only! - simulate a week
	
	public final static int DAILY_TASKS = 1;
	public final static int WEEKLY_TASKS = 2;
	
	private Timer DailyTasks = null;
	private Timer WeeklyTasks = null;

	protected EchoServer server;
	protected mysqlConnection SqlDB;
		

	/**
	 * Constructor for Scheduler
	 */
	public Scheduler(EchoServer server,mysqlConnection SqlDB){ //Client/mainGui,SqlDB ????
		
		this.server = server;
		this.SqlDB = SqlDB;
		
		DailyTasks = new Timer();
		DailyTasks.schedule(new SchedTask(DAILY_TASKS,this),0L,DAY_IN_MILLIES_PRESENTATION); //0L - Zero In Long - To Set Start Date - Will Start When The Program Starts To Run
		
		
		//WeeklyTasks = new Timer();
		//WeeklyTasks.schedule(new SchedTask(WEEKLY_TASKS,this),0L,WEEK_IN_IN_MILLIES_PRESENTATION);
	}
	
public EchoServer getServer(){
	return(this.server);
	}

public mysqlConnection getSqlDB(){
	return(this.SqlDB);
	}
}
